unit ufrmcadpadrao;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, db, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  Buttons, ActnList, StdCtrls, DBGrids,uFuncoes, sqldb;

type

  { TFrmCadPadrao }

  TFrmCadPadrao = class(TForm)
    APesquisar: TAction;
    AFechar: TAction;
    AInserir: TAction;
    ASalvar: TAction;
    ACancelar: TAction;
    AImprimir: TAction;
    AExcluir: TAction;
    ALC1: TActionList;
    BtnFechar: TBitBtn;
    BtnPesquisar: TBitBtn;
    BtnInserir: TBitBtn;
    BtnSalvar: TBitBtn;
    BtnCancelar: TBitBtn;
    BtnExcluir: TBitBtn;
    BtnImprimir: TBitBtn;
    DS1: TDataSource;
    PNLBotoes: TPanel;
    procedure ACancelarExecute(Sender: TObject);
    procedure AExcluirExecute(Sender: TObject);
    procedure AFecharExecute(Sender: TObject);
    procedure AInserirExecute(Sender: TObject);
    procedure ASalvarExecute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  FrmCadPadrao: TFrmCadPadrao;

implementation



{$R *.lfm}

{ TFrmCadPadrao }

procedure TFrmCadPadrao.AInserirExecute(Sender: TObject);
begin
  DS1.DataSet.Insert;
end;

procedure TFrmCadPadrao.ACancelarExecute(Sender: TObject);
begin
  DS1.DataSet.Cancel;
end;

procedure TFrmCadPadrao.AExcluirExecute(Sender: TObject);
begin
  DS1.DataSet.Delete;
  TSQLQuery(DS1.DataSet).ApplyUpdates(0);
  TSQLTransaction(TSQLQuery(DS1.DataSet).Transaction).CommitRetaining;
end;

procedure TFrmCadPadrao.AFecharExecute(Sender: TObject);
begin
  Close;
end;

procedure TFrmCadPadrao.ASalvarExecute(Sender: TObject);
begin
  DS1.DataSet.Post;
  TSQLQuery(DS1.DataSet).ApplyUpdates(0);
  TSQLTransaction(TSQLQuery(DS1.DataSet).Transaction).CommitRetaining;

end;

procedure TFrmCadPadrao.FormCreate(Sender: TObject);
begin
  TFuncoes.AbrirDataSourcesForm(Self);
end;

end.

